home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / BWinTutorial2.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  7.5 KB  |  239 lines

  1. /* This is the base for a never written tutorial */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. /* init our world */
  7. call Init
  8.  
  9. /* create the application */
  10. call createApp
  11.  
  12. /* open the window */
  13. call set("win","open",1)
  14.  
  15. /* handle the application */
  16. call handleApp
  17.  
  18. /* this point is never reached */
  19. /***********************************************************************/
  20. Init: procedure
  21.     /* add the needed libraries */
  22.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  23.     if AddLibrary("rxmui.library")~=0 then exit
  24.     call ProgDir()
  25.     return
  26. /***********************************************************************/
  27. handleApp: procedure
  28.     /* this is the standard cycle to handle an application */
  29.     ctrl_C=2**12
  30.     do forever
  31.     call NewHandle("app","h",ctrl_c)
  32.     if and(h.signals,ctrl_c)>0 then exit
  33.     if h.EventFlag then
  34.         select
  35.             when h.event="QUIT" then exit
  36.             otherwise interpret h.event
  37.         end
  38.     end
  39.     /* this point is never reached */
  40. /***********************************************************************/
  41. createApp: procedure
  42.  
  43.     /* first of all the let's define the application object */
  44.     app.Title="Tutorial2"
  45.     app.Version="$VER: Tutorial2 1.2 (4.11.2002)"
  46.     app.Copyright="Copyright 1999-2002 by Alfonso Ranieri"
  47.     app.Author="Alfonso Ranieri"
  48.     app.Description="Just a little example"
  49.     app.Base="EXAMPLE"
  50.     app.DiskObject="PROGDIR:tutorial2"
  51.  
  52.     /* this is the menu strip */
  53.     app.menustrip="strip"
  54.      strip.class="Menustrip"
  55.      strip.0="mproject"
  56.       mproject.Title="Project"
  57.       mproject.class="menu"
  58.        mproject.0=menuitem("mabout","?\About...")
  59.        mproject.1=menuitem("maboutrxmui","X\About RxMUI...")
  60.        mproject.2=menuitem("maboutmui","!\About MUI...")
  61.        mproject.3=menuitem("","BAR")
  62.        mproject.4=menuitem("mhide","H\Hide")
  63.        mproject.5=menuitem("","BAR")
  64.        mproject.6=menuitem("mquit","Q\Quit")
  65.  
  66.      /* this is the main (and only) window */
  67.     app.SubWindow="win"
  68.      win.Class="BWin"
  69.      win.ID="MAIN"
  70.      win.Title="A Tutorial"
  71.  
  72.       /* the window contents */
  73.      win.Contents="mgroup"
  74.  
  75.       mgroup.0="dg"
  76.        dg.Class="group"
  77.        dg.Frame="group"
  78.        dg.Background="GroupBack"
  79.        dg.Columns=2
  80.  
  81.         dg.0=label("_Name");
  82.          name.CycleChain=1
  83.          name.AdvanceOnCR=1
  84.         dg.1=String("name",'n')
  85.  
  86.         dg.2=Label("_Age");
  87.          age.CycleChain=1
  88.         dg.3=MakeObj(,"HLeft",MakeObj("Age","NumericButton","a",0,150,30))
  89.  
  90.         dg.4=Label("_Sex","Double")
  91.          sex.CycleChain=1
  92.         dg.5=MakeObj(,"HLeft",MakeObj("Sex","Radio","Male|Female","_Sex",,1))
  93.  
  94.         dg.6=Label("_Knowledge");
  95.          known.CycleChain=1
  96.         dg.7=MakeObj("known","Cycle","Novice|Average|Good|Expert","_Knowledge")
  97.  
  98.         dg.8=Label("Language(s)")
  99.         dg.9="lg"
  100.          lg.class="group"
  101.          lg.horiz=1
  102.            BASIC.CycleChain=1
  103.           lg.0=Checkmark("BASIC",,'b')
  104.           lg.1=Label("_Basic")
  105.           lg.2=HSPace()
  106.            ARexx.CycleChain=1
  107.           lg.3=Checkmark("ARexx",,'x')
  108.           lg.4=Label("ARe_xx")
  109.            C.CycleChain=1
  110.           lg.5=HSPace()
  111.           lg.6=Checkmark("C",,'c')
  112.           lg.7=Label("_C")
  113.           lg.8=HSPace()
  114.            ASM.CycleChain=1
  115.           lg.9=Checkmark("ASM",,'m')
  116.           lg.10=Label("AS_M")
  117.           lg.11=hvspace()
  118.  
  119.       /* to use a crawling you must set its height
  120.          as large as the first object */
  121.       mgroup.1="cr"
  122.        cr.class="crawling"
  123.        cr.Frame="Text"
  124.        cr.Background="TextBack"
  125.        cr.FixHeightTxt="0a"x
  126.  
  127.         /* this is the first object */
  128.         parse value(RxMUIOpt("Ask")) with . v date .
  129.         cr.0="t0"
  130.          t0.class="text"
  131.          t0.contents=ParseText("%c%bRxMUI%n" v date "\n
  132. Copyright 1999-2002 by Alfonso Ranieri")
  133.  
  134.         /* this is the second object (you could insert other) */
  135.         cr.1="t1"
  136.          t1.class="text"
  137.          t1.contents=ParseText("%c\n
  138. Please fill this registration form\n
  139. and send to <alforan@tin.it>\n
  140. You will receive a RxMUI ver. 3 key file!\n")
  141.  
  142.         /* repeating the first object at the end makes
  143.            the crawling smoother */
  144.         cr.2="t2"
  145.          t2.class="text"
  146.          t2.contents=t0.contents
  147.  
  148.       mgroup.2="bg"
  149.        bg.class="group"
  150.        bg.columns=3
  151.          reset.CycleChain=1
  152.         bg.0=Button("reset","_Reset Form")
  153.          done.CycleChain=1
  154.         bg.1=Button("done","_Done")
  155.          cancel.CycleChain=1
  156.         bg.2=Button("cancel","Cance_l")
  157.  
  158.     /* create all */
  159.     call NewObj("APPLICATION","APP")
  160.  
  161.     /* window close gadget means quit */
  162.     call Notify("win","CloseRequest",1,"app","ReturnID","QUIT")
  163.  
  164.     /* reset pressed -> reset all to defaults */
  165.     call Notify("reset","pressed",0,"app","Return","call reset")
  166.  
  167.     /* done pressed -> print all */
  168.     call Notify("done","pressed",0,"app","Return","call print")
  169.  
  170.     /* cancel pressed -> exit */
  171.     call Notify("cancel","pressed",0,"app","returnid","quit")
  172.  
  173.     /* about menuitem means show the automatic about requester */
  174.     call Notify("mabout","menutrigger","Everytime","app","about","win")
  175.  
  176.     /* aboutrxmui menuitem means show the rxmui about requester */
  177.     call Notify("maboutrxmui","menutrigger","everytime","app","aboutrxmui","win")
  178.  
  179.     /* aboutmui menuitem means show the about MUI window */
  180.     call Notify("maboutmui","menutrigger","everytime","app","aboutmui","win")
  181.  
  182.     /* hide menuitem means hide all windows (just one here) */
  183.     call Notify("mhide","menutrigger","everytime","app","set","iconified",1)
  184.  
  185.     /* quit menu item means quit */
  186.     call Notify("mquit","menutrigger","everytime","app","returnid","quit")
  187.  
  188.     /* Add user items to BWin popup menu */
  189.     call DoMethod("win","AddUserItem","ResetForm ",1)
  190.     call DoMethod("win","AddUserItem","Done ",2)
  191.     call Notify("Win","UserItem",1,"app","Return","call reset")
  192.     call Notify("Win","UserItem",2,"app","Return","call print")
  193.  
  194.     call set("win","activeobject","done")
  195.  
  196.     return
  197. /***********************************************************************/
  198. halt:
  199. break_c:
  200.     exit
  201. /**************************************************************************/
  202. reset: procedure
  203.     set.0="name";  set.0.attr="Contents"; set.0.value=""
  204.     set.1="age";   set.1.attr="Value";    set.1.value=30
  205.     set.2="Sex";   set.2.attr="Active";   set.2.value=0
  206.     set.3="known"; set.3.attr="Active";   set.3.value=0
  207.     set.4="BASIC"; set.4.attr="Selected"; set.4.value=0
  208.     set.5="ARexx"; set.5.attr="Selected"; set.5.value=0
  209.     set.6="C";     set.6.attr="Selected"; set.6.value=0
  210.     set.7="ASM";   set.7.attr="Selected"; set.7.value=0
  211.     call MultiSetAttr("set")
  212.     return
  213. /**************************************************************************/
  214. print: procedure
  215.     get.0="name";  get.0.attr="Contents"
  216.     get.1="age";   get.1.attr="Value"
  217.     get.2="Sex";   get.2.attr="Active"
  218.     get.3="known"; get.3.attr="Active"
  219.     get.4="BASIC"; get.4.attr="Selected"
  220.     get.5="ARexx"; get.5.attr="Selected"
  221.     get.6="C";     get.6.attr="Selected"
  222.     get.7="ASM";   get.7.attr="Selected"
  223.     call MultiGetAttr("get")
  224.     if get.0.value="" then do
  225.         call set("win","ActiveObject","name")
  226.         return
  227.     end
  228.     say " Name:" get.0.value
  229.     say "  Age:" get.1.value
  230.     say "  Sex:" word("Male Female",get.2.value+1)
  231.     say "Known:" word("Novice Average Good Expert",get.3.value+1)
  232.     say "BASIC:" word("Unknown Known ",get.4.value+1)
  233.     say "ARexx:" word("Unknown Known ",get.5.value+1)
  234.     say "    C:" word("Unknown Known ",get.6.value+1)
  235.     say "  ASM:" word("Unknown Known ",get.7.value+1)
  236.  
  237.     return
  238. /**************************************************************************/
  239.